package com.zhang.crm;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zhang.crm.pojo.TDicValue;
import com.zhang.crm.pojo.TProduct;
import com.zhang.crm.service.DicTypeService;
import com.zhang.crm.service.ProductService;
import jakarta.annotation.Resource;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@SpringBootApplication
@MapperScan("com.zhang.crm.mapper")
public class CrmApplication implements CommandLineRunner{

    @Resource
    public DicTypeService dicTypeService;

    @Resource
    public ProductService productService;
    public static void main(String[] args) {
        SpringApplication.run(CrmApplication.class, args);
    }

    public static  Map<String, List<TDicValue>> dicCacheMap = new HashMap<>();

    public static List<TProduct> productList = new ArrayList<>();

    @Override
    public void run(String... args) throws Exception {
        //加载字典数据到内存
        dicCacheMap = dicTypeService.loadDicToMemory();
        //加载意向产品
        productList = productService.loadProductList();

    }
}
